<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">借支人</label>
                        <div class="layui-input-block">
                            <input type="text" name="gonger" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年份</label>
                        <div class="layui-input-block">
                            <input type="text" readonly id="year" name="year" placeholder="请选择" autocomplete="off" class="layui-input bdate_sea_y">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var date = new Date();
    var year = date.getFullYear();
    $("#year").val(year);


    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('备用金台账');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_payment_jie_tai_payment),where: {year:year}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'gonger', title: '借支人'}
                ,{field: 'year', title: '年度'}
                ,{field: 'lei_jie', title: '备用金累计借支(元)',align:'right',totalRow: true,event: 'payment_jie',templet: function(d){
                    if(d.gonger){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_jie)+'</span>';
                    }else{
                        return '<span class="">'+parseFormatNum(d.lei_jie)+'</span>';
                    }
                }}
                ,{field: 'lei_jiezhi', title: '备用金累计支付(元) A',align:'right',totalRow: true,event: 'payment_jie',templet: function(d){
                    if(d.gonger){
                            return '<span class="colorlan">'+parseFormatNum(d.lei_jiezhi)+'</span>';
                    }else{
                            return '<span class="">'+parseFormatNum(d.lei_jiezhi)+'</span>';
                    }
                }}
                ,{field: 'lei_di', title: '累计报销冲抵(元) B',align:'right',totalRow: true,event: 'payment_jie',templet: function(d){
                    if(d.gonger){
                            return '<span class="colorlan">'+parseFormatNum(d.lei_di)+'</span>';
                    }else{
                            return '<span class="">'+parseFormatNum(d.lei_di)+'</span>';
                    }
                }}
                ,{field: 'huanfee', title: '累计还款(元) C',align:'right',totalRow: true,event: 'payment_jie',templet: function(d){
                    if(d.gonger){
                        return '<span class="colorlan">'+parseFormatNum(d.huanfee)+'</span>';
                    }else{
                        return '<span class="">'+parseFormatNum(d.huanfee)+'</span>';
                    }
                }}
                ,{field: 'daihuan', title: '累计待还(元) D=A-B-C',align:'right',totalRow: true,event: 'payment_jie',templet: function(d){
                    if(d.gonger){
                        return '<span class="colorlan">'+parseFormatNum(d.daihuan)+'</span>';
                    }else{
                        return '<span class="">'+parseFormatNum(d.daihuan)+'</span>';
                    }
                }}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;

            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'payment_jie'){
                openPage('../payment_jie/tong.php?gonger='+encodeURI(data.gonger)+'&status=1&year='+data.year, '80%', '80%');
            }


        });

        listTableSearch(form, table);
    });




</script>
</body>
</html>
